package com.duoec.dw.lineage.service.analyser.expr;

import com.alibaba.druid.sql.ast.expr.SQLUnaryExpr;
import com.duoec.dw.lineage.dto.MultiTableLineageDto;
import com.duoec.dw.lineage.dto.TableFieldDependencyDto;
import org.springframework.stereotype.Service;

import java.util.LinkedHashSet;

/**
 * @author xuwenzhen
 */
@Service
public class UnaryExprAnalyser extends BaseExprAnalyser<SQLUnaryExpr> {
    /**
     * 获取匹配类型
     *
     * @return 类型
     */
    @Override
    public Class<SQLUnaryExpr> getSqlExprType() {
        return SQLUnaryExpr.class;
    }

    /**
     * 分析表达式语句
     *
     * @param expr         表达式语句
     * @param fromLineages 当前语句from解析出来的血缘关系
     * @return 此表达式抽取出来的依赖
     */
    @Override
    public LinkedHashSet<TableFieldDependencyDto> analyse(SQLUnaryExpr expr, MultiTableLineageDto fromLineages) {
        return hiveAnalyser.analyseExpr(fromLineages, expr.getExpr());
    }
}
